const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const config = require('./config/config');
const sequelize = require('./config/database');
const answerRoute = require('./routes/answerRoute');

const app = express();

// 中间件
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());

// 路由
app.use('/API', answerRoute);

// 启动应用程序
sequelize.sync().then(() => {
  app.listen(config.port, () => {
    console.log(`Server started on port ${config.port}`);
  });
});